#include "ScnsIic.c.h"

#if defined(SCNS_IIC_ENABLE)&&SCNS_IIC_ENABLE==1

#include "ScnsMath.h"

const ScnsBspIicConfig scnsBspIicConfig[SCNS_IIC_MAX]={
    {.tick=1000},
};

void scnsBspIicSetSdaDir(ScnsIicEnum iicN,uint8 in)
{
    const uint32 hb=scnsMathGetHighest1(IIC1_SDA_Pin)*2;
    IIC1_SDA_GPIO_Port->MODER&=~(3<<(hb));
    if(!in) IIC1_SDA_GPIO_Port->MODER|=1<<(hb);
}

void scnsBspIicSetScl(ScnsIicEnum iicN,uint8 dat)
{
    IIC1_SCL_GPIO_Port->BSRR=(dat)?(IIC1_SCL_Pin):(IIC1_SCL_Pin<<16);
}

void scnsBspIicSetSda(ScnsIicEnum iicN,uint8 dat)
{
    IIC1_SDA_GPIO_Port->BSRR=(dat)?(IIC1_SDA_Pin):(IIC1_SDA_Pin<<16);
}

uint8 scnsBspIicGetSda(ScnsIicEnum iicN)
{
    return (IIC1_SDA_GPIO_Port->IDR&IIC1_SDA_Pin)?1:0;
}

#endif
